<?php

namespace api\modules\v1\controllers\patient;

use services\patient\PatientOrderService;
use services\shop\ShopService;
use services\spoker\SpokerService;
use Yii;
use api\controllers\OnAuthController;

class PatientOrderController extends OnAuthController
{
    public $modelClass = '';

    /**
     * @api {get} /v1/patient/patient-order/index 预约列表
     * @apiGroup PatientOrder
     * @apiName index
     * @apiUse CommonParam
     *
     * @apiParam {string} order_stime       预约开始时间
     * @apiParam {string} order_etime       预约结束时间
     * @apiParam {int} spoker_id            代言人ID
     * @apiParam {int} shop_id              门店ID
     * @apiParam {int} status               状态【1已预约(等待到院)、2到院、3过期】
     * @apiParam {int} page
     * @apiParam {int} pageSize
     *
     * @apiSuccess {Object}  data
     * @apiSuccess {Object}  data.list                  列表数据
     * @apiSuccess {Number}  data.list.id               列表ID
     * @apiSuccess {String}  data.list.patient_name     患者名称
     * @apiSuccess {String}  data.list.treatment_project_name       项目类型
     * @apiSuccess {String}  data.list.order_time_str               预约时间
     * @apiSuccess {String}  data.list.shop_name                    预约门店
     * @apiSuccess {String}  data.list.status_name                  状态【1已预约(等待到院)、2到院、3过期】
     * @apiSuccess {String}  data.list.patient_order_name           代言人
     *
     */
    public function actionIndex()
    {
        $params = Yii::$app->request->get();
        $page = $params['page'] ?? 1;
        $pageSize = $params['pageSize'] ?? 10;
        $service = new PatientOrderService();
        $list['list'] = $service->patientOrderList($params, $page, $pageSize);
        $list['condition'] = [
            'spoker_arr' => SpokerService::getListCondition(),
            'shop_arr' => ShopService::getListCondition(),
            'status_arr' => PatientOrderService::getStatusCondition(),
        ];
        return $list;
    }
}
